import tv.zarate.Utils.Delegate;
/**
* Clase de control para Flash Paper
* 
*/


class com.dxdesign.paper.FlashPaper {
	var loader:MovieClipLoader;
	private var _mc:MovieClip;
	private var _paperUI:Object;
	private var _paperPagesCount:Number;
	private var _alto:Number;
	private var _ancho:Number;
	
	private var _intervalo:Number;
	private var _secondLoop:Boolean;
	
	private var _srcpaper;
	
	function FlashPaper(src,ancho,alto){
		_srcpaper=src;
		_alto=alto;
		_ancho=ancho;
		
		loader=new MovieClipLoader();
		loader.addListener(this);
	}
	function load(mc){
		this._secondLoop=false;
		loader.loadClip(_srcpaper, mc);
		_mc=mc;
	}
	

	
	function onLoadInit(target_mc:MovieClip){
		
		_intervalo=setInterval(Delegate.create(this,setProp) , 200);
	}
	
	
	
	private function setProp(){
		_paperUI = _mc.getIFlashPaper();
		if(!_paperUI ){
			return;
		}
		if(this._secondLoop){
			_paperUI.setSize(_ancho, _alto);
			clearInterval(_intervalo);
		}else{
			
		
			_paperPagesCount=_paperUI.getNumberOfPages();
		
			_paperUI.setSize(_ancho, _alto);
		
			_paperUI.showUIElement("PrevNext", true);
			_paperUI.showUIElement("Print", true);
			_paperUI.showUIElement("Find", false);
			_paperUI.showUIElement("Tool", false);
			_paperUI.showUIElement("Pop", false);
			_paperUI.showUIElement("Zoom", true);
			_paperUI.showUIElement("Page", false);
			_paperUI.showUIElement("Overflow", true);
			_paperUI.enableScrolling(true);
			_paperUI.setCurrentZoom(100);
			this._secondLoop=true;
		}
	}
	
	function remove(){
		if(_paperUI)
		_mc.unloadMovie();
	}
	
	function imprimir(){
		if(_paperUI){
			_paperUI.printTheDocument();
		}
	}
}